package com.lzy.huijinjiazu.mvp.ui.activity;

import android.os.Bundle;
import android.text.Html;
import android.view.View;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.flyco.roundview.RoundTextView;
import com.gyf.barlibrary.ImmersionBar;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import com.lzy.huijinjiazu.R;
import com.lzy.huijinjiazu.di.component.DaggerRegisterComponent;
import com.lzy.huijinjiazu.di.module.RegisterModule;
import com.lzy.huijinjiazu.mvp.contract.RegisterContract;
import com.lzy.huijinjiazu.mvp.presenter.RegisterPresenter;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;


public class RegisterActivity extends BaseActivity<RegisterPresenter> implements RegisterContract.View {


    @BindView(R.id.iv_back)
    ImageView mIvBack;
    @BindView(R.id.fl_title)
    FrameLayout mFlTitle;
    @BindView(R.id.iv_register)
    ImageView mIvRegister;
    @BindView(R.id.et_pwd)
    EditText mEtPwd;
    @BindView(R.id.ll_pwd)
    LinearLayout mLlPwd;
    @BindView(R.id.et_code)
    EditText mEtCode;
    @BindView(R.id.tv_code)
    RoundTextView mTvCode;
    @BindView(R.id.ll_code)
    LinearLayout mLlCode;
    @BindView(R.id.tv_commit)
    RoundTextView mTvCommit;
    @BindView(R.id.tv_login)
    TextView mTvLogin;
    private boolean isFristStep = true;

    @Override
    public void setupActivityComponent(AppComponent appComponent) {
        DaggerRegisterComponent //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .registerModule(new RegisterModule(this))
                .build()
                .inject(this);
    }

    @Override
    public int initView(Bundle savedInstanceState) {
        return R.layout.activity_register; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
    }

    @Override
    public void initData(Bundle savedInstanceState) {
        mTvLogin.setText(Html.fromHtml(ArmsUtils.getString(this, R.string.immediately_login)));
    }

    @Override
    protected void initImmersionBar() {
        super.initImmersionBar();
        mImmersionBar.setTitleBarMarginTop(this, mFlTitle);
    }

    @OnClick({R.id.iv_back, R.id.tv_commit})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.iv_back:
                finish();
                break;
            case R.id.tv_commit:
                if (isFristStep) {
                    isFristStep = !isFristStep;
                    mTvCommit.setText("注册");
                    mIvRegister.setBackgroundResource(R.mipmap.bg_register2);
                    mLlPwd.setVisibility(View.GONE);
                    mLlCode.setVisibility(View.VISIBLE);
                    return;
                }
                break;
        }
    }

}
